package com.ljw.spring.annotation.tx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.UUID;

/**
 * @FileName UserDao
 * @Description TODO
 * @Author ljw
 * @Date 2021/2/4 0:38
 * @Version 1.0
 */
@Repository
public class UserDao {
    @Autowired
    JdbcTemplate jdbcTemplate;
    public void insert(){
        String sql="INSERT INTO `tb_user`(username,age) VALUES(?,?)";
        String s = UUID.randomUUID().toString().substring(0, 4);
        int update = jdbcTemplate.update(sql, s, 20);
        System.out.println("成功插入一条数据！");
    }
}
